package leetcode_core.leetcode_4;

import org.junit.Test;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;

/**
 * 功能描述
 *
 * @author: 张庭杰
 * @date: 2022年10月30日 11:48
 */
public class LetterCasePermutation {
    private List<String> list = new ArrayList<>();
    private void backtrack(String s,int i,StringBuilder track,int len){
        if(i == len){
            list.add(track.toString());
            return;
        }
        if(Character.isDigit(s.charAt(i))){
            track.append(s.charAt(i));
            backtrack(s,i+1,track,len);
            track.deleteCharAt(i);
        }else{
            char[] chose = {s.charAt(i),Character.toUpperCase(s.charAt(i))};
            for (char c : chose) {
                track.append(c);
                backtrack(s,i+1,track,len);
                track.deleteCharAt(i);
            }
        }
    }

    public List<String> letterCasePermutation(String s) {
        StringBuilder track = new StringBuilder();
        backtrack(s.toLowerCase(),0,track,s.length());
        return list;
    }
    @Test
    public void test(){
        letterCasePermutation("a1b2");
    }
}
